<extend name="Base/common" />
<block name="header">
    <header class="jumbotron subhead" id="overview">
        <div class="container">
            <h2>设置头像</h2>
            <p><span><span class="pull-left"></span></span></p>
        </div>
    </header>
</block>
<block name="body">
    <section>
        <div class="span12">
            <form class="login-form" action="__SELF__" method="post">
                <div class="form-row">
                    <div class="form-l">
                        <div><b>缩略图</b></div>
                        <p></p>
                    </div>
                    <div class="form-content">
                        <!-- 给  class="uploadify" 或者 id="upload_picture_thumb" 添加按钮样式-->
                        <input type="file" id="upload_picture_thumb">
                        <input type="hidden" name="avatar" class="JS_field" id="cover_id_thumb" value="{$avatar}">
                        <!-- upload-img-box 上传后预览 给样式和限制图片大小 -->
                        <div class="upload-img-box"><notempty name="avatar"><div class="upload-pre-item"><img src="__ROOT__{$avatar}"></div></notempty></div>
                        <!-- class="uploadify-queue" id="upload_picture_thumb-queue"  自动添加的上传进度条 给样式或者隐藏 -->
                    </div>
                </div>
                <div class="control-group">
                    <div class="controls"><button type="submit" class="btn">提 交</button></div>
                </div>
            </form>
        </div>
    </section>
</block>
<block name="side"></block>
<block name="script">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript">
    //上传图片
    /* 初始化上传插件 */
    $("#upload_picture_thumb").uploadify({
        "width": 120,
        "height": 30,
        "swf": "__STATIC__/uploadify/uploadify.swf",
        "fileObjName": "download",
        "buttonText": "上传图片",
        "uploader": "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
        'removeTimeout': 1,
        'fileTypeExts': '*.jpeg; *.jpg; *.png; *.gif;',
        "onUploadSuccess": uploadpicturethumb,
        'onFallback': function() {
            alert('未检测到兼容版本的Flash.');
        }
    });

    function uploadpicturethumb(file, data) {
        var data = $.parseJSON(data);
        var src = '';
        if (data.status) {
            $("#cover_id_thumb").val(data.path);
            src = data.url || '__ROOT__' + data.path
            $("#cover_id_thumb").parent().find('.upload-img-box').html(
                '<div class="upload-pre-item"><img src="' + src + '"/></div>'
            );
        } else {
            updateAlert(data.info);
            setTimeout(function() {
                $('#top-alert').find('button').click();
                $(that).removeClass('disabled').prop('disabled', false);
            }, 1500);
        }
    }
    </script>
</block>